<ng-template #btnTpl let-i let-btn="btn" let-sub="sub">
  <nz-popconfirm *ngIf="btn.pop === true" [nzTitle]="btn.popTitle" (nzOnConfirm)="_btnClick(i, btn)">
    <a *ngIf="!sub" nz-popconfirm>
      <ng-template [ngTemplateOutlet]="btnTextTpl" [ngTemplateOutletContext]="{ $implicit: i, btn: btn }"></ng-template>
    </a>
    <span *ngIf="sub" nz-popconfirm>
      <ng-template [ngTemplateOutlet]="btnTextTpl" [ngTemplateOutletContext]="{ $implicit: i, btn: btn }"></ng-template>
    </span>
  </nz-popconfirm>
  <ng-container *ngIf="btn.pop !== true">
    <a *ngIf="!sub" (click)="_btnClick(i, btn)">
      <ng-template [ngTemplateOutlet]="btnTextTpl" [ngTemplateOutletContext]="{ $implicit: i, btn: btn }"></ng-template>
    </a>
    <span *ngIf="sub" (click)="_btnClick(i, btn)">
      <ng-template [ngTemplateOutlet]="btnTextTpl" [ngTemplateOutletContext]="{ $implicit: i, btn: btn }"></ng-template>
    </span>
  </ng-container>
</ng-template>
<ng-template #btnTextTpl let-i let-btn="btn">
  <ng-container *ngIf="btn.icon">
    <i *ngIf="!btn.icon.iconfont"
       nz-icon [nzType]="btn.icon.type"
       [nzTheme]="btn.icon.theme"
       [nzSpin]="btn.icon.spin"
       [nzTwotoneColor]="btn.icon.twoToneColor"></i>
    <i *ngIf="btn.icon.iconfont" nz-icon [nzIconfont]="btn.icon.iconfont"></i>
  </ng-container>
  <span [innerHTML]="_btnText(i, btn)" [ngClass]="{'pl-xs': btn.icon}"></span>
</ng-template>


<nz-table #expandTable nzBordered="true" nzSize="middle" [nzData]="listOfMapData">
  <thead>
  <tr>
    <th *ngFor="let colum of columns">{{colum.title}}</th>
  </tr>
  </thead>
  <tbody>
  <ng-container *ngFor="let data of expandTable.data">
    <ng-container *ngFor="let item of mapOfExpandedData[data.key]">
      <tr *ngIf="(item.parent && item.parent.expand) || !item.parent">
        <ng-container *ngFor="let colum of columns;let i = index">
          <td *ngIf="i==0" [nzIndentSize]="item.level * 20"
              [nzShowExpand]="!!item.children"
              [(nzExpand)]="item.expand"
              (nzExpandChange)="collapse(mapOfExpandedData[data.key], item, $event)">
            {{ item[colum.index] }}
          </td>
          <td *ngIf="i!=0">
            <ng-container *ngIf="!colum.buttons">
              {{ item[colum.index] }}
            </ng-container>
            <ng-container *ngIf="colum.buttons">
              <ng-container *ngFor="let button of colum.buttons">
                <ng-template [ngTemplateOutlet]="btnTpl" [ngTemplateOutletContext]="{ $implicit: item, btn: button, sub: true }"></ng-template>
              </ng-container>
            </ng-container>
          </td>
        </ng-container>
      </tr>
    </ng-container>
  </ng-container>
  </tbody>
</nz-table>
